# encoding=utf8
import sys
import time
import math
reload(sys)
sys.setdefaultencoding('utf8')

class JT_8700:
    LatStrInfo = ""
    LongStrInfo = ""
    skr=""
    def AnalysisLat(self, source):
        # double Lat;
        try:
            Lat = int(source, 16) * math.pow(10, -6);
            # self.LatStrInfo = String.format("%.6f", Lat);
            self.LatStrInfo = "%.6f" % Lat
        except:
            pass

    def AnalysisLong(self, source):
        # double Long;
        try:
            Long = int(source, 16) * math.pow(10, -6);
            # self.LongStrInfo = String.format("%.6f", Long);
            self.LongStrInfo = "%.6f" % Long
        except:
            pass

    def LogicAisle(self, protocolStr, header):
     result=[]
     count=0
     t=0
     s = protocolStr[count:count + 2]
     header.append("命令字:"+s)
     count=count+2
     s = protocolStr[count+2:count + 4]
     if s=="7e":
         pass
     else:
         s = protocolStr[count:count + 2]
         header.append("起始字头:" + s+"\n")
         count = count + 2
         s = protocolStr[count:count + 2]
         header.append("起始字头:" + s + "\n")
         count = count + 2
         s = protocolStr[count:count + 2]
         skr=s
         header.append("命令字:" + s + "\n")
         count = count + 2

         s = protocolStr[count:count + 4]
         print(s)
         n=int(s,16)
         header.append("数据块长度:" + str(n) + "\n")
         count = count + 4

         s = protocolStr[count:count + 2]
         header.append("保留（备用）字 :" + s + "\n")
         count = count + 2

         header.append("数据块:" )
         if skr=="00":
             pass
         elif skr=="01":
             pass
         elif skr=="02":
             pass
         elif skr=="03":
             pass
         elif skr=="04":
             pass
         elif skr=="05":
             pass
         elif skr=="06":
             pass
         elif skr=="07":
             pass
         elif skr=="08":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4


         elif skr== "09":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr=="10":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr=="11":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr=="12":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr== "13":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr== "14":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
         elif skr== "15":
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("开始时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 12]
             c = 0
             t = s[c:c + 2]
             header.append("结束时间：" + t)
             c = c + 2
             for i in range(5):
                 t = s[c:c + 2]
                 header.append("-" + t)
                 c = c + 2
             header.append("\n")
             count = count + 12
             s = protocolStr[count:count + 4]
             print(s)
             n = int(s, 16)
             header.append("最大单位数据块个数 N:" + str(n) + "\n")
             count = count + 4
     s = protocolStr[-6:-4]
     header.append("校验字：" + s)
     self.result = header
